#include <climits>
#include <iostream>
#include <string>
#include <vector>
using namespace std;

class Solution {
public:
    string longestCommonPrefix(vector<string>& strs)
    {
        int min_size = INT_MAX;
        string common_prefix = "";
        if (strs.empty())
            return common_prefix;
        for (int i = 0; i < strs.size(); i++) {
            if (strs[i].size() < min_size)
                min_size = strs[i].size();
        }
        for (int i = 0; i < min_size; i++) {
            char current_char = strs[0][i];
            bool flag = true;
            for (int j = 1; j < strs.size(); j++) {
                if (strs[j][i] != current_char)
                    return common_prefix;
            }
            if (flag)
                common_prefix += current_char;
        }
        return common_prefix;
    }
};

int main(int argc, char const* argv[])
{
    Solution temp;
    vector<string> strs;
    strs.push_back("aca");
    strs.push_back("cba");
    string result = temp.longestCommonPrefix(strs);
    cout << result;
    return 0;
}